﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Reflection;
using Game;
using Game.Handlers;
using System.Data.Sql;
using System.Data.SqlClient;
using System.Data.OleDb;

namespace GirlTrainer
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        #region Function Calls for outside resources
        Game.FormLoad fl = new Game.FormLoad();
        Game.Toolbar_Code tb = new Game.Toolbar_Code();
        #endregion

        private void Form1_Load(object sender, EventArgs e)
        {
            this.Text = fl.FormTitle;
            this.startText.Text = fl.StartText;
            this.startImage.SizeMode = PictureBoxSizeMode.StretchImage;
            this.startImage.Image = LoliTrainer.Properties.Resources.lolicream1;
        }

        private void quitToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (CanSave == false)
            {
                tb.QuitWithOutSave();
            }
            else
            {
                tb.Quit();
            }
        }

        private void loadToolStripMenuItem_Click(object sender, EventArgs e)
        {
            
            if (CanSave == false)
            {
                MessageBox.Show("No Saved Games");
            }
            else
            {
                LoadGame lg = new LoadGame();
                this.Hide();
                lg.ShowDialog();
            }
        }

        private void saveToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (CanSave == false)
            {
                MessageBox.Show("Please Create a Game First");
            }
            else
            {

                //dbm.oconn.Close();
            }

        }

        private void aboutToolStripMenuItem_Click(object sender, EventArgs e)
        {
            LoliTrainer.AboutBox1 ab1 = new LoliTrainer.AboutBox1();
            ab1.ShowDialog();
        }

        private void toolStripMenuItem1_Click(object sender, EventArgs e)
        {
            Game.Settings gs = new Game.Settings();
            gs.ShowDialog();
        }

        private void btn_Start_Click(object sender, EventArgs e)
        {
            this.Hide();
            Game.TrainerCreator tc = new Game.TrainerCreator();
            tc.ShowDialog();
        }

        private void btn_Load_Click(object sender, EventArgs e)
        {
            
            if (CanSave == false)
            {
                MessageBox.Show("No Saved Games");
            }
            else
            {
                LoadGame lg = new LoadGame();
                this.Hide();
                lg.ShowDialog();
            }
        }

        DBManager dbm = new DBManager();
        #region Save Yes or No?
        public bool CanSave
        {
            get
            {
                //dbm.ORead("SELECT `ID` FROM `Characters`");
                //DataSet ds = new DataSet();
                if (dbm.DT("SELECT `ID` FROM `Characters`").Rows.Count == 0)
                {
                    return false;
                }
                else
                {
                    return true;
                }
            }
            set { }

        }
        #endregion
    }
}
